package us.ajg0702.leaderboards.libs.hikari.metrics.prometheus;

import io.prometheus.client.CollectorRegistry;
import us.ajg0702.leaderboards.libs.hikari.metrics.IMetricsTracker;
import us.ajg0702.leaderboards.libs.hikari.metrics.MetricsTrackerFactory;
import us.ajg0702.leaderboards.libs.hikari.metrics.PoolStats;


public class PrometheusHistogramMetricsTrackerFactory
        implements MetricsTrackerFactory {
    private HikariCPCollector collector;
    private final CollectorRegistry collectorRegistry;

    public PrometheusHistogramMetricsTrackerFactory() {
        this.collectorRegistry = CollectorRegistry.defaultRegistry;
    }


    public PrometheusHistogramMetricsTrackerFactory(CollectorRegistry collectorRegistry) {
        this.collectorRegistry = collectorRegistry;
    }


    public IMetricsTracker create(String poolName, PoolStats poolStats) {
        getCollector().add(poolName, poolStats);
        return new PrometheusHistogramMetricsTracker(poolName, this.collectorRegistry);
    }


    private HikariCPCollector getCollector() {
        if (this.collector == null) {
            this.collector = (HikariCPCollector) (new HikariCPCollector()).register(this.collectorRegistry);
        }
        return this.collector;
    }
}


*Location:D:\User\Xuan\Downloads\ajLeaderboards-1.3.3.jar\\us\ajg0702\leaderboards\libs\hikari\metrics\prometheus\PrometheusHistogramMetricsTrackerFactory.class
 *Java compiler version:8(52.0)
         *JD-Core Version:1.1.3
